const Router = require("koa-router")
const {resolve} = require("path")
const golp = require("golp")
const symbolPrefix = symbol("prefix")
const loadsh = symbol("loadsh")
const routerMap = new map()

export class Route {
    constructor (app,apiPath) {
        this.app = app
        this.apiPath = apiPath
        this.router = new Router()
    }
    init () {
        golp.sync(resolve(this.apiPath,'./**/.js')).foreach(require)
        for (let ) {

        }
    }
}

const normolizePath = path => path.startsWith("/") ? path : `/${path}`

const router = conf => (target,key,descriptor) => {
    conf.path = normolizePath(conf.path)
    routerMap.set({
        target: target,
        ...conf
    },target.key)
}

const controller = path => target => (target.prototype[symbolPrefix] = path)

const get = path => router({
    method: "get",
    path: path
})

const post = path => router({
    method: "post",
    path: path
})

const del = path => router({
    method: "del",
    path: path
})

const use = path => router({
    method: "use",
    path: path
})

const all = path => router({
    method: "all",
    path: path
})